package org.sunshinebox.team.sweettest.easymock;

import java.lang.reflect.Field;
import java.util.List;

import org.easymock.EasyMock;
import org.sunshinebox.team.sweettest.Tools;

public class EasyMockTools extends Tools{
	
	@Override
	public void setup() {
		List<Field> fieldList = super.getMockedFields();
		for (Field field : fieldList) {
			Class<?> clazz = field.getType();
			super.setFieldValue(field,EasyMock.createMock(clazz));
		}
	}
	
	@Override
	public void arm() {
		List<Field> fieldList = super.getMockedFields();
		for (Field field : fieldList) {
			Object mock = super.getFieldValue(field);
			EasyMock.replay(mock);
		}
	}

	@Override
	public void verify() {
		List<Field> fieldList = super.getMockedFields();
		for (Field field : fieldList) {
			Object mock = super.getFieldValue(field);
			EasyMock.verify(mock);
			setFieldValue(field, null);
		}
	}
}
